package com.flink.jdbc;

import com.alibaba.fastjson.JSONObject;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author hujf
 * @Date 2022/8/31 11:25
 * @Description TODO
 */
public class JDBCTemplate {

    public static List<String> getData(String type, String url, String data) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String username = "xx";
            String password = "xx";
            Connection connection = DriverManager.getConnection(url, username, password);

            Statement statement = connection.createStatement();

            ResultSet rs = statement.executeQuery(data);
            List a = new ArrayList();
            while (rs.next()) {
                String string = rs.getString(1);
                a.add(string);
            }
            return a;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
